package com.zff.rental.repository.apartment;

import com.zff.rental.entity.apartment.ApartmentManager;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * @author HCY
 */
@Repository
public interface ApartmentManagerRepository extends JpaRepository<ApartmentManager, ApartmentManager.MId> {
    void deleteByApartmentId(Long apartmentId);

    List<ApartmentManager> findAllByApartmentId(Long apartmentId);

    Optional<ApartmentManager> findOneByApartmentIdAndUserId(Long apartmentId, Long userId);

    boolean existsByApartmentIdAndUserId(Long apartmentId, Long userId);

    List<ApartmentManager> findAllByApartmentIdAndIsButler(Long apartmentId, Byte isButler);

    @Override
    boolean existsById(@NotNull ApartmentManager.MId id);
}
